using System;
using SharpMud.Net.Telnet.Session.NegotationAgents;

namespace SharpMud.Net.Telnet.Session
{
	/// <summary>
	/// This class is just a nice, friendly-named container for some agents that perform
	/// friendly, front-end tasks using low-level telnet protocols.
	/// </summary>
	public class StandardAgentsPlatform : IDisposable
	{
		#region Private Variables
		private TelnetSessionBase _HostSession;

		private NegotationAgents.RemoteEcho				_RemoteEcho;
		private NegotationAgents.GoAhead				_GoAhead;
		private NegotationAgents.EndOfRecord			_EndOfRecord;
		private NegotationAgents.TerminalType			_TerminalType;
		private NegotationAgents.NAWS					_NAWS;
		private NegotationAgents.MCCP					_MCCP;
		private NegotationAgents.MXP					_MXP;
		#endregion

		#region Constructors
		private StandardAgentsPlatform()
		{
		}
		public StandardAgentsPlatform(TelnetSessionBase hostSession)
		{
			Init(hostSession);
		}

		private void Init(TelnetSessionBase hostSession)
		{
			this._HostSession = hostSession;
			
			_RemoteEcho = new SharpMud.Net.Telnet.Session.NegotationAgents.RemoteEcho(this.HostSession);
			_RemoteEcho.Behavior = FeatureNegotiationBehavior.DemandClientSupport;

			_GoAhead	= new SharpMud.Net.Telnet.Session.NegotationAgents.GoAhead(this.HostSession);
			_GoAhead.Enabled = true;

			_EndOfRecord= new SharpMud.Net.Telnet.Session.NegotationAgents.EndOfRecord(this.HostSession);
			_GoAhead.Enabled = true;

			_TerminalType= new SharpMud.Net.Telnet.Session.NegotationAgents.TerminalType(this.HostSession);
			_TerminalType.Behavior = FeatureNegotiationBehavior.DemandClientSupport;

			_NAWS = new SharpMud.Net.Telnet.Session.NegotationAgents.NAWS(this.HostSession);
			_NAWS.Behavior = FeatureNegotiationBehavior.DemandClientSupport;

			_MXP = new SharpMud.Net.Telnet.Session.NegotationAgents.MXP(this.HostSession);
			_MXP.Behavior = FeatureNegotiationBehavior.DemandClientSupport;
			_MXP.TurnFeatureOn();

			_MCCP = new SharpMud.Net.Telnet.Session.NegotationAgents.MCCP(this.HostSession);
			_MCCP.Behavior = FeatureNegotiationBehavior.DemandClientSupport;
			
			_Init();
		}
		protected virtual void _Init() {}
		#endregion

		#region Public Properties
		protected TelnetSessionBase				HostSession		{get{return this._HostSession;}}

		public NegotationAgents.RemoteEcho					RemoteEcho		{get{return this._RemoteEcho;}}
		public NegotationAgents.GoAhead						GoAhead			{get{return this._GoAhead;}}
		public NegotationAgents.EndOfRecord					EndOfRecord		{get{return this._EndOfRecord;}}
		public NegotationAgents.TerminalType				TerminalType	{get{return this._TerminalType;}}
		public NegotationAgents.NAWS						NAWS			{get{return this._NAWS;}}
		public NegotationAgents.MCCP						MCCP			{get{return this._MCCP;}}
		public NegotationAgents.MXP							MXP				{get{return this._MXP;}}
		#endregion

        public void Dispose()
        {
            //Nothing to dispose
        }
    }
}